import request from '@/utils/request'

export function list(params) {
  return request({
    url: '/api/dashboard/v1/guest',
    params
  })
}

export function detail(id) {
  return request({
    url: `/api/dashboard/v1/guest/${id}`
  })
}

export function add(data) {
  return request({
    url: '/api/dashboard/v1/guest',
    method: 'post',
    data
  })
}

export function update(data) {
  return request({
    url: `/api/dashboard/v1/guest/${data.id}`,
    method: 'put',
    data
  })
}

export function change(data) {
  const url = !data.status ? `/api/dashboard/v1/guest/${data.id}/resume` : `/api/dashboard/v1/guest/${data.id}/forbid`
  return request({
    url,
    method: 'patch'
  })
}
export function set(data) {
  const url = !data.is_card ? `/api/dashboard/v1/ticket/${data.id}/setcard` : `/api/dashboard/v1/ticket/${data.id}/cancelcard`
  return request({
    url,
    method: 'patch'
  })
}

export function remove(id) {
  return request({
    url: `/api/dashboard/v1/guest/${id}`,
    method: 'delete'
  })
}
